# -*- coding:utf-8 -*-
import time

import datetime

from Public_way.AutoTestLog import Logger
from selenium.webdriver.support.ui import WebDriverWait


class LowDoctorV:
    def __init__(self, driver):
        self.driver = driver

    def LowVideo(self):
        logger2 = Logger()
        WebDriverWait(self.driver, 10).until(lambda x: x.find_element_by_name('首页')).click()
        logger2.log('会诊医生-进入到首页')
        money = WebDriverWait(self.driver, 10).until(
            lambda x: x.find_element_by_id('com.jkgj.skymonkey.doctor:id/fragment_home_tv_money'))
        logger2.log('会诊医生-视频之前-余额为：%s' % money.text.encode('utf-8'))
        # 等待会诊弹窗
        WebDriverWait(self.driver, 500).until(lambda x: x.find_element_by_name('前往查看')).click()
        logger2.log('会诊医生进入会诊页面')
        WebDriverWait(self.driver, 50).until(
            lambda x: x.find_element_by_id('com.jkgj.skymonkey.doctor:id/iv_patient_avatar')).click()
        logger2.log('会诊医生进入会诊详情')
        WebDriverWait(self.driver, 500).until(
            lambda x: x.find_element_by_id('com.jkgj.skymonkey.doctor:id/ll_go_server')).click()
        logger2.log('会诊医生点击进入会诊-进入视频，等待患者挂断视频')
        getMoney = WebDriverWait(self.driver, 500).until(
            lambda x: x.find_element_by_id('com.jkgj.skymonkey.doctor:id/tv_total_money'))
        logger2.log('会诊医生此次视频收入：%s' % getMoney)
        WebDriverWait(self.driver, 50).until(
            lambda x: x.find_element_by_id('com.jkgj.skymonkey.doctor:id/rl_back')).click()
        WebDriverWait(self.driver, 50).until(
            lambda x: x.find_element_by_id('com.jkgj.skymonkey.doctor:id/back_rl')).click()
        logger2.log('会诊医生返回到首页了，查看总余额')
        allmoney = WebDriverWait(self.driver, 10).until(
            lambda x: x.find_element_by_id('com.jkgj.skymonkey.doctor:id/fragment_home_tv_money'))
        logger2.log('会诊医生-视频后-余额为：%s' % allmoney.text.encode('utf-8'))
